<?php
mysql_connect("localhost","root","") or die("koneksi gagal");
mysql_select_db("db_pro_amdk1.2") or die(mysql_error());

//base64_encode
function filter($word){	  
	$word = stripslashes(trim($word));	  
	$word = nl2br($word);	  
	$word = htmlentities($word, ENT_QUOTES);
	$word = mysql_real_escape_string($word);	  
	return $word ;  
}

function strip_single($tag,$string){
	$string=preg_replace('/<'.$tag.'[^>]*>/i', '', $string);
	$string=preg_replace('/<\/'.$tag.'>/i', '', $string);
	return $string;
}

function limit_words($string, $word_limit)
{
    $words = explode(" ",$string);
    return implode(" ",array_splice($words,0,$word_limit));
}

function sukses($message,$url){
	echo "<script>alert('".$message."');window.location='".$url."';</script>";
}

function difference_date($start_date,$end_date){
	$pecah1 = explode("-",$start_date);
	$pecah2 = explode("-",$end_date);

	$jd1 = gregoriantojd($pecah1[1], $pecah1[2], $pecah1[0]);
	$jd2 = gregoriantojd($pecah2[1], $pecah2[2], $pecah2[0]);

	return ($jd2-$jd1);
}


?>